var api = require('../../utils/api.js');
var app = getApp();

Page({

    /**
     * 页面的初始数据 getalllist
     */
    data: {
        lists:[]
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onShow() {

        this.getallmoban();
    },

    getallmoban(){
        var that=this;
        api.post({
            url: 'moban/getalllist',
            data: {},
            success: data => {
                console.log(data);
                that.setData({
                    lists:data.data
                })
            }
        });

    },

    seeinfo(ret){
        console.log(ret);
        var id=ret.currentTarget.dataset.id;
        wx.navigateTo({
          url: '/pages/moban/info?id='+id
        })
    },
    seeok(ret){
        console.log(ret);
        var id=ret.currentTarget.dataset.id;
        
        var that=this;
        api.post({
            url: 'moban/seemobanbyid',
            data: {id:id},
            success: data => {
                console.log(data);
                that.getallmoban();

                wx.showToast({
                  title: data.msg,
                  icon:'none'
                })
            }
        });
    },
    alloks(){
        var that=this;
        api.post({
            url: 'moban/seemoban',
            data: {},
            success: data => {
                console.log(data);
                that.getallmoban();
            }
        });

    }

})